<template>
  <div>
    <!-- <h2 @click="save">内容编辑</h2>
    <WangEditor @saveArticle="saveArticle" @click="save" />
    <span v-html="htmla"></span>
    <el-button type="primary" @click="saveArticle">保存</el-button>
    <el-button type="primary" @click="add">+++</el-button> -->
  </div>
</template>

<script lang="ts" setup>
// import { reactive, ref, onMounted } from "vue";
// import WangEditor from "./WangEditor.vue";
// import { creatVaccineResult, selectVaccineResultsByPatientId } from "../api/vaccineResults";
// import { useRoute, useRouter } from "vue-router";
// import { creatClinicalResult } from "../api/clinicalResults";

// const route = useRoute();
// const router = useRouter();

// const articleContent = ref("");

// // 父组件的方法
// const saveArticle = async (data: string) => {
//   // 这里可以添加保存文章的逻辑，例如调用API保存到服务器
//   console.log("Article saved:", data);
//   articleContent.value = data;
//   const pName = route.query.pName;

//   switch (pName) {
//     case "VaccineDesign": { //调用疫苗接口
//       try {
//         const Result = {
//           patientId: route.query.patientId,
//           vaccineName: "周秀英*************",
//           teamDesigner: "道",
//           antigenType: "角",
//           content: articleContent.value,
//         };
//         const response = await creatVaccineResult(Result);
//       //   console.log("VaccineDesign response:", response);
//       } catch (error) {
//         console.error("Error in VaccineDesign API call:", error);
//       }
//       return;
//     }
//     case "ClinicalObservation": { //调用临床用药接口
//       try {
//         const Result = {
//           patientId: route.query.patientId,
//           content: articleContent.value,
//         };
//         const response = await creatClinicalResult(Result);
//         // console.log("ClinicalObservation response:", response);
//       } catch (error) {
//         console.error("Error in VaccineDesign API call:", error);
//       }
//       return;
//     }
//     default:
//       console.log("无匹配情况");
//       return;
//   }
//   alert("文章已保存！");
// };

// const save = () => {
//   console.log(route.query, route.query.patientId);
// };

// const htmla = ref("");
// htmla.value =
//   '<p>模拟 Ajax 异步设置内容<img src="http://localhost:8080/static/2024-07-181721273004_a.png" alt="a.png" data-href="http://localhost:8080/static/2024-07-181721273004_a.png" style=""/></p>';

</script>
